#!/usr/bin/env bash
dt="`date -d "$d  0 days ago "  "+%Y-%m-%d"`"
mysql -ureadonly -preadonly123 -h192.168.0.49<<EOF
use jiayou;
select from_unixtime(a.created,'%Y-%m-%d')as day, a.use_shop_id,SUM(b.actual_amoun)
from coupon_info  as a
join coupon_info_ext as b
on a.id = b.coupon_id
where coupon_statue = 3 and a.coupon_type = 99 and from_unixtime(a.created,'%Y-%m-%d')='$dt'
group by a.use_shop_id,from_unixtime(a.created,'%Y-%m-%d');
EOF